<template>
  <div class="production">
    <div v-for="(item, index) in tableList" :key="index">
      <a-card class="cardBox">
        <template slot="title">
          <my-icon type="icon-dingdan" style="color: #3599FF;" />
          &nbsp;订单名称&nbsp;{{ item.orderName }}
        </template>
        <div class="flex flex-wrap">
          <div class="working_box" v-for="(item1, index1) in item.workingProcedureResultList" :key="index1">
            <a-row class="titleBox">
              <a-col :span="8">
                <span class="title_label">工序名称</span>
                <span class="title_value">{{ item1.workingProcedureName }}</span>
              </a-col>
              <a-col :span="8">
                <span class="title_label">加工程序名</span>
                <span class="title_value" @click="handleDetail(item.id)">{{ item1.procedureName }}</span>
              </a-col>
            </a-row>
            <a-table :bordered="true" :columns="columns" :data-source="item1.workingProcedureItemResultList"></a-table>
          </div>
        </div>
      </a-card>
    </div>
  </div>
</template>

<script>
import { Icon } from 'ant-design-vue';
const myIcon = Icon.createFromIconfontCN({
  scriptUrl: '//at.alicdn.com/t/font_3218058_7vlgj7vvxjc.js',
});
import api from '@/api/production.js';
export default {
  data() {
    return {
      columns: [
        {
          dataIndex: 'macNum',
          title: '加工设备',
          key: 'macNum',
          align: 'center',
        },
        {
          title: '已完成件数',
          dataIndex: 'finishNum',
          key: 'finishNum',
          align: 'center',
        },
        {
          title: '起止时间',
          dataIndex: 'startAndEndDate',
          key: 'startAndEndDate',
          align: 'center',
        },
      ],
      tableList: [],
      Params: {}, // 接口参数
    };
  },
  components: {
    myIcon,
  },
  created() {
    let roleId = localStorage.getItem('roleId');
    if (roleId == 1) {
      this.Params.companyId = localStorage.getItem('compid');
      this.getList();
    } else {
      this.Params.companyId = localStorage.getItem('choseCompanyId');
      this.getList();
    }
  },
  methods: {
    //  获取列表数据
    async getList() {
      const res = await api.getProductionList(this.Params);
      if (res.msgCode === 0) {
        this.tableList = res.data;
      }
    },
  },
};
</script>

<style scoped lang="less">
@import 'index';
</style>
